﻿<?php
/**
 * This is the file to define MemberList.
 * 
 * @author	KyungMo Kim <kyungmo.kim@kyowyourrights.org.au>
 * @version	0.0.1.0001
 * @package	KYR.Components
 * 
 */

//	Checks if this file is called within the framework; otherwise terminates.
if (!defined("IS_FRAMEWORK") || !IS_FRAMEWORK)	header("Location: http://".$_SERVER["HTTP_HOST"]."/error/404");

//	Imports relevant files.
require_once CORE_PATH."KYR.Core.BaseComponent.php";

/**
 * This is class MemberList that displays the list of members.
 *
 * Displays the list of members.
 * 
 * @author	KyungMo Kim <kyungmo.kim@kyowyourrights.org.au>
 * @package	KYR.Components
 * 
 */
class MemberList extends BaseComponent
{
	/**
	 * Initiates the MemberList class.
	 *
	 * @access	public
	 * @param	Request	$request	Request object that contains page request details.
	 * @param	int		$objectID	Either moduleID or widgetID that calls the component.
	 * @param	string	$mappedBy	Flag whether the component is called by a module or widget.
	 * @param	int		$statusCode	Page status code.
	 * @exception					Throws an Exception while initialising the class.
	 *
	 */
	public function __construct($request, $objectID, $mappedBy, $statusCode = 200)
	{
		parent::__construct($request, $objectID, $mappedBy, $statusCode);
		$this->componentName = __CLASS__;

		if ($this->statusCode == 200)
		{
			try
			{
				$this->CheckComponent_();
				if (!$this->existComponent)
					throw new Exception("Component not found");
			}
			catch (Exception $ex) { throw $ex; }
		}
		else
			$this->existComponent = true;
		//	Creates controls for this component.
		$this->CreateControls_();
	}
	
	/**
	 * Creates a set of controls to be used in templates called by the component.
	 *
	 * @access	protected
	 *
	 */
	protected function CreateControls_()
	{
	}
	
	/**
	 * Processes the component.
	 *
	 * @access	public
	 * @param	array	$variables	Set of data to be stored by the component.
	 * @exception					Throws an Exception while processing the component.
	 *
	 */
	public function ProcessComponent(&$variables)
	{
		//	Processes get/post.
		$this->ProcessRequest($variables);
		
		//	Sets the controls.
		$this->SetControls_($variables);

		//	Processes the parent method.
		try { $this->ProcessComponent_($variables); } catch (Exception $ex) { throw $ex; }

		//	Processes handlers
		if (isset($this->handlers) && count($this->handlers) > 0)
			foreach ($this->handlers as $handler)
				$handler->ProcessHandler($variables);
	}

	/**
	 * Processes the requests within the page.
	 *
	 * @access	public
	 * @param	array	$variables	The set of GET/POST variables.
	 * @exception		$ex			Throws an exception while processing the request.
	 *
	 */
	public function ProcessRequest(&$variables)
	{
		try
		{
			if ($this->request->isAjax)
				$this->ProcessAJAX($variables);
			else
				$this->ProcessGetPost($variables);
		}
		catch (Exception $ex) { throw $ex; }
	}
	
	/**
	 * Processes the AJAX requests within the page.
	 *
	 * @access	public
	 * @param	array	$variables	The set of GET/POST variables.
	 * @exception		$ex			Throws an exception while processing the request.
	 *
	 */
	public function ProcessAJAX(&$variables)
	{
		try
		{
		}
		catch (Exception $ex) { throw $ex; }
	}
	
	/**
	 * Processes the GET/POST requests within the page.
	 *
	 * @access	public
	 * @param	array	$variables	The set of GET/POST variables.
	 * @exception		$ex			Throws an exception while processing the request.
	 *
	 */
	public function ProcessGetPost(&$variables)
	{
		try
		{
		}
		catch (Exception $ex) { throw $ex; }
	}

	/**
	 * Sets the set of controls to be used in templates called by the component.
	 *
	 * @access	protected
	 * @param	array	$variables	Set of data generated by the component.
	 * @exception					Throws an Exception while setting data onto the controls.
	 *
	 */
	protected function SetControls_(&$variables)
	{
	}
}
?>
